home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src_ansi / ace / c / lexvar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  6.7 KB  |  172 lines

  1. /* << ACE >> 
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Lexical Analyser Variable Declarations ** 
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.    Date: 19th October-30th November, 3rd-12th December 1991,
  24.    14th,27th January 1992, 5th,7th-17th, 
  25.    23rd-24th February 1992,
  26.    14th,22nd March 1992,
  27.    21st April 1992,
  28.    2nd,11th,15th May 1992,
  29.    7th,8th,9th,11th,13th,14th,28th June 1992,
  30.    2nd-6th,8th,14th-19th,26th,28th,29th July 1992,
  31.    1st,9th August 1992,
  32.    6th,22nd,27th-29th December 1992,
  33.    2nd,14th February 1993,
  34.    6th June 1993,
  35.    1st July 1993,
  36.    5th,26th September 1993,
  37.    26th October 1993,
  38.    17th,24th,26th December 1993,
  39.    2nd,3rd January 1994,
  40.    6th February 1994,
  41.    10th July 1994,
  42.    22nd August 1994,
  43.    6th October 1995,
  44.    22nd June 1996,
  45.    4th September 1996
  46.  */
  47.  
  48. #include "acedef.h"
  49.  
  50. /* globals */
  51. BOOL report_errors = TRUE;    /* eg. see assem() in misc.c */
  52.  
  53. /* externals */
  54. extern ACELIBS acelib[NUMACELIBS], otherlib[NUMLIBS];
  55.  
  56. extern int exitvalue;
  57.  
  58. extern BOOL early_exit;
  59. extern BOOL error_log;
  60. extern BOOL asm_comments;
  61. extern BOOL list_source;
  62.  
  63. /* sorted list of reserved words */
  64. char *rword[] =
  65. {
  66.     /* AmigaBASIC reserved words */
  67.   "ABS", "ALL", "AND", "APPEND", "AREA", "AREAFILL",
  68.   "AS", "ASC", "ATN", "BASE", "BEEP", "BREAK", "CALL", "CDBL",
  69.   "CHAIN", "CHDIR", "CHR$", "CINT", "CIRCLE", "CLEAR", "CLNG",
  70.   "CLOSE", "CLS", "COLLISION", "COLOR", "COMMON", "CONT",
  71.   "COS", "CSNG", "CSRLIN", "CVD", "CVI", "CVL", "CVS", "DATA",
  72.   "DATE$", "DECLARE", "DEF", "DEFDBL", "DEFINT", "DEFLNG",
  73.   "DEFSNG", "DEFSTR", "DELETE", "DIM", "ELSE", "ELSEIF", "END",
  74.   "EOF", "EQV", "ERASE", "ERL", "ERR", "ERROR", "EXIT", "EXP",
  75.   "FIELD", "FILES", "FIX", "FN", "FOR", "FRE", "FUNCTION",
  76.   "GET", "GOSUB", "GOTO", "HEX$", "IF", "IMP", "INKEY$",
  77.   "INPUT", "INPUT$", "INSTR", "INT", "KILL", "LBOUND", "LEFT$",
  78.   "LEN", "LET", "LIBRARY", "LINE", "LIST", "LLIST", "LOAD", "LOC",
  79.   "LOCATE", "LOF", "LOG", "LPOS", "LPRINT", "LSET", "MENU", "MERGE",
  80.   "MID$", "MKD$", "MKI$", "MKL$", "MKS$", "MOD", "MOUSE", "NAME",
  81.   "NEW", "NEXT", "NOT", "OBJECT.AX", "OBJECT.AY", "OBJECT.CLIP",
  82.   "OBJECT.CLOSE", "OBJECT.HIT", "OBJECT.OFF", "OBJECT.ON",
  83.   "OBJECT.PLANES", "OBJECT.PRIORITY", "OBJECT.SHAPE",
  84.   "OBJECT.START", "OBJECT.STOP", "OBJECT.VX", "OBJECT.VY",
  85.   "OBJECT.X", "OBJECT.Y", "OCT$", "OFF", "ON", "OPEN", "OPTION", "OR",
  86.   "OUTPUT", "PAINT", "PALETTE", "PATTERN", "PEEK", "PEEKL", "PEEKW",
  87.   "POINT", "POKE", "POKEL", "POKEW", "POS", "PRESET", "PRINT", "PSET",
  88.   "PTAB", "PUT", "RANDOMIZE", "READ", "REM", "RESTORE", "RESUME",
  89.   "RETURN", "RIGHT$", "RND", "RSET", "RUN", "SADD", "SAVE", "SAY",
  90.   "SCREEN", "SCROLL", "SGN", "SHARED", "SIN", "SLEEP", "SOUND",
  91.   "SPACE$", "SPC", "SQR", "STATIC", "STEP", "STICK", "STOP", "STR$",
  92.   "STRIG", "STRING$", "SUB", "SWAP", "SYSTEM", "TAB", "TAN", "THEN",
  93.   "TIME$", "TIMER", "TO", "TRANSLATE$", "TROFF", "TRON", "UBOUND",
  94.   "UCASE$", "USING", "VAL", "VARPTR", "WAIT", "WAVE", "WEND", "WHILE",
  95.   "WIDTH", "WINDOW", "WRITE", "XOR",
  96.  
  97.     /* ACE-specific reserved words */
  98. "ADDRESS", "ALLOC", "ARG$", "ARGCOUNT", "ASSEM", "BACK", "BEVELBOX", "BIN$",
  99.   "BLOCK", "BUTTON", "BYTE", "CASE", "CONST", "CSTR", "DAY", "EXTERNAL", "FILEBOX$",
  100.   "FONT", "FORWARD", "GADGET", "GLOBAL", "HANDLE", "HEADING", "HOME", "IFF", "INPUTBOX",
  101.   "INPUTBOX$", "LONGINT", "MESSAGE", "MSGBOX", "PENDOWN", "PENUP", "POTX",
  102.   "POTY", "PRINTS", "REPEAT", "SERIAL", "SETHEADING", "SETXY", "SHL", "SHORTINT",
  103.   "SHR", "SINGLE", "SIZE", "SIZEOF", "STRING", "STRUCT", "STYLE", "TURN",
  104.   "TURNLEFT", "TURNRIGHT", "TURTLE", "UNTIL", "XCOR", "YCOR",
  105.  
  106.   "SENTINEL"};
  107.  
  108. /* reserved symbols */
  109. char *rsym[] =
  110. {"++", "--", "*%", "*&", "*!", "->", "+\0", "-\0", "*\0", "/\0", "\\\0", "^\0",
  111.  "(\0", ")\0", ",\0", "'\0", ";\0", ":=", ":\0", "?\0", "<>", "<=", ">=",
  112.  "=\0", "<\0", ">\0", "#\0", "&O", "&H", "@\0", "eoln\0", "SENTINEL"};
  113.  
  114. /* special characters (for reserved symbols) */
  115. char spec_sym[] = "=+-*/\\^(),.';:?<>@";
  116.  
  117. /* other symbols apart from reserved words */
  118. char *symbol[] =
  119. {"shortconst", "longconst", "singleconst", "doubleconst",
  120.  "stringconst", "ident"};
  121.  
  122. /* objects */
  123. char *object[] =
  124. {"variable", "array", "subprogram", "function", "extfunc",
  125.  "extvar", "label", "constant", "structdef", "structure",
  126.  "reserved word"};
  127.  
  128. /* data types */
  129. char *type[] =
  130. {"bytetype", "shorttype", "longtype", "singletype", "doubletype",
  131.  "stringtype", "notype"};
  132.  
  133. /* --character handler-- */
  134. char *srcfile, *destfile;    /* source and destination file names */
  135. FILE *src;            /* source file handle */
  136. FILE *dest;            /* object file handle */
  137. int column, linelen;        /* current column & length of char buffer */
  138. int lineno = 0;            /* current line of source */
  139. int errors = 0;            /* # of errors generated */
  140. char line[MAXLINELEN];        /* Nth line buffer */
  141. char lastline[MAXLINELEN];    /* (N-1)th line buffer */
  142. char ch = ' ';            /* last character returned by nextch */
  143. char ut_ch;            /* same as ch, but not forced to upper case */
  144. BOOL end_of_source = FALSE;    /* indicates whether EOF reached */
  145. BOOL std_in = FALSE;        /* is source file stdin? (used for testing) */
  146.  
  147. /* --scanner-- */
  148. FILE *err_log;            /* error log file */
  149. int sym = undefined;        /* last symbol returned by scanner */
  150. int lastsym;            /* symbol from LAST scanner call */
  151. int obj;            /* kind of object (label,variable...) */
  152. int typ;            /* type (short,long,string...) */
  153. char id[MAXIDSIZE];        /* identifier */
  154. char ut_id[MAXIDSIZE];        /* untouched identifier for DATA statement */
  155. char stringval[MAXSTRLEN];    /* string literal */
  156. SHORT shortval;            /* short literal */
  157. LONG longval;            /* long literal */
  158. float singleval;        /* single precision literal */
  159. double doubleval;        /* double precision literal */
  160. SHORT dimsize[255];        /* array indices holder */
  161.  
  162. int idtype[31];            /* 
  163.                    ** Type of ident starting with a given letter 
  164.                    ** or an underscore which is ASCII 95, hence
  165.                    ** 31 positions: 0..25 = A..Z and 30 = "_"
  166.                    ** 
  167.                    ** Although positions 26..29 are wasted,
  168.                    ** this scheme is elegant.
  169.                    **
  170.                    ** The default datatype is SINGLE.
  171.                  */
  172.